/**
 * 
 */
package com.eagle.coders.core.action.meta.processor;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;

/**
 * @author anees
 *
 */
public class MetaInformation {

	
	private static final String META_PATH = "META-INF/search-table/"; 
	
	private String usecaseId;
	private String metaPath;
	private Enumeration<URL> searchableInResource;
	private Enumeration<URL> searchTableOutResource;
	
	public MetaInformation(String usecaseId){
		this(usecaseId, null);
	}
	
	public MetaInformation(String usecaseId, String metaPath){
		this.usecaseId = usecaseId;
		if(null == metaPath)
			this.metaPath = META_PATH;
		else
			this.metaPath = metaPath;
		init();
	}
	
	/**
	 * 
	 */
	private void init(){
		initializeIn();
		initializeOut();
	}
	
	/**
	 * 
	 */
	private void initializeIn(){
		try{
			searchableInResource = this.getClass().getClassLoader().getResources("META-INF/search-table/"+usecaseId+".in");
		}catch(NullPointerException npe){
			
			npe.printStackTrace();
			
		}catch(IOException ioe){
			ioe.printStackTrace();
		}
	}
	
	/**
	 * 
	 */
	private void initializeOut(){
		try{
			searchTableOutResource = this.getClass().getClassLoader().getResources("META-INF/search-table/"+usecaseId+".out");
		}catch(NullPointerException npe){
			
			npe.printStackTrace();
			
		}catch(IOException ioe){
			ioe.printStackTrace();
		}
	}
	
	/**
	 * 
	 * @return
	 */
	public UsecaseMetaOutActionProcessor getMetaOutActionProcessor(){
		return new UsecaseMetaOutActionProcessor(searchTableOutResource);
	}
}
